package com.company;

import java.util.Scanner;

/**
 * 编写程序，使用数组，保存10个随机数，然后对其进行升序排序
 */
public class demo07 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);int[] a = new int[10];
        for (int i = 0; i <= a.length - 1; i++) {
            int b = (int) Math.ceil(Math.random() * 20);a[i] = b;
        }
            System.out.println("---排序前---");for (int c : a) {
            System.out.print(c + " ");
        }
        for (int i=0;i<a.length-1;i++){
            for (int j=0;j<a.length-1-i;j++){
                if (a[j]>a[j+1]){
                    int d = a[j];a[j] = a[j+1];a[j+1] = d;
                }
            }
        }
        System.out.println("");
        System.out.println("---排序后---");for (int s : a) {
            System.out.print(s + " ");

    }
}
}
